#ifndef _COMPONENT_H_
#define _COMPONENT_H_

#include <string>
#include <SECore/Serializable.h>

namespace SEngine
{
    class Actor;
    struct IComponent
    {
        ENABLE_SERIALIZE_BASE
        IComponent(Actor & actor) : m_actor(actor) {}
        virtual ~IComponent() = default;
        virtual size_t Hash() = 0;
        virtual std::string Name() = 0;
        virtual void Attach() {}
        virtual void Detach() {}
        virtual void BeforeUpdate() {}
        virtual void OnUpdate(int delta) {}
        virtual void AfterUpdate() {}
        Actor & m_actor;
        bool m_vaild{true};
        bool m_enabled{true};
    };

    template<typename T>
    struct Component : public IComponent
    {
        using CompType = T;
        Component(Actor & actor) : IComponent(actor) {}
        virtual ~Component() = default;
        size_t Hash() override {
            return typeid(T).hash_code();
        }
        std::string Name() override {
            return typeid(T).name();
        }
    };

} // namespace SEngine


#endif